package com.nidu.demo.menu;

import com.alibaba.cola.dto.MultiResponse;
import com.alibaba.cola.dto.PageResponse;
import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.nidu.demo.common.enums.StatusEnum;
import com.nidu.demo.menu.api.SysMenuService;
import com.nidu.demo.menu.dto.*;
import com.nidu.demo.menu.executor.command.*;
import com.nidu.demo.menu.executor.query.*;
import com.nidu.demo.menu.ability.MenuDomainService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Set;

/**
 * 菜单服务实现类
 *
 * @author auto
 */
@Service
@RequiredArgsConstructor
public class SysMenuServiceImpl implements SysMenuService {

    private final MenuAddCmdExe addCmdExe;
    private final MenuUpdateCmdExe updateCmdExe;
    private final MenuDeleteCmdExe deleteCmdExe;
    private final MenuSingleQryExe singleQryExe;
    private final MenuListQryExe listQryExe;
    private final MenuPageQryExe pageQryExe;
    private final MenuDomainService menuDomainService;

    @Override
    public SingleResponse<MenuCO> add(MenuAddCmd cmd) {
        return addCmdExe.execute(cmd);
    }

    @Override
    public SingleResponse<MenuCO> update(MenuUpdateCmd cmd) {
        return updateCmdExe.execute(cmd);
    }

    @Override
    public Response delete(Long id) {
        return deleteCmdExe.execute(id);
    }

    @Override
    public Response delete(Set<Long> ids) {
        return deleteCmdExe.execute(ids);
    }

    @Override
    public SingleResponse<MenuCO> getById(Long id) {
        return singleQryExe.execute(id);
    }

    @Override
    public MultiResponse<MenuCO> list(MenuListQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public MultiResponse<MenuTreeCO> tree(MenuTreeQry qry) {
        return listQryExe.execute(qry);
    }

    @Override
    public PageResponse<MenuTreeCO> page(MenuPageQry qry) {
        return pageQryExe.execute(qry);
    }

    @Override
    public Response updateStatus(Long id, StatusEnum status) {
        menuDomainService.updateStatus(id, status);
        return Response.buildSuccess();
    }
} 